<template>
  <div>
    <template>
      <div slot="header" class="clearfix" style="text-align: center;line-height: 30px">
        <h3>供应商退货审核</h3>
      </div>
      <el-table
          :data="providerAudit"
          border
          style="width: 100%">
        <el-table-column
            prop="ordernumber"
            label="订单编号">
        </el-table-column>
        <el-table-column
            prop="buynumber"
            label="采购编号">
        </el-table-column>
        <el-table-column
            prop="num"
            label="数量">
        </el-table-column>
        <el-table-column
            prop="returndate"
            label="日期">
        </el-table-column>
        <el-table-column
            prop="returntype"
            label="退货状态">
        </el-table-column>
        <el-table-column
            prop="returnmoney"
            label="退款状态">
        </el-table-column>
        <el-table-column
            fixed="right"
            label="审核">
          <template slot-scope="scope">
            <el-button @click="handleClick(scope.row)" type="button" size="small">审核</el-button>
          </template>
        </el-table-column>
      </el-table>

      <el-dialog
          :visible.sync="dialogVisible"
          width="45%"
          :before-close="handleClose">
        <SupplierreturnLook ref="child1" @closeDialog="closeWin" @initDialog="init" :usercodeTag="usercodeTag"></SupplierreturnLook>
      </el-dialog>

      <div class="block">
        <el-pagination
            @size-change="handleSizeChange"
            @current-change="handleCurrentChange"
            :current-page="pageNum"
            :page-sizes="[6, 8, 10, 12]"
            :page-size="100"
            layout="total, sizes, prev, pager, next, jumper"
            :total="total">
        </el-pagination>
      </div>
    </template>
  </div>
</template>

<script>

import SupplierreturnLook from "@/components/SupplierreturnLook";

export default {
  name: "SupplierreturnSell",
  components:{
    SupplierreturnLook
  },
  data(){
    return{
      pageNum: 1,
      pageSize: 6,
      total: '',
      providerAudit:[],
      messageget:'',
      dialogVisible:false,
      usercodeTag:''
    }
  },
  mounted() {
    this.init()
  },
  methods:{
    init(){
      let url = '/csc/supplierreturn/byTyprGetSupplierreturn/0/'+ this.pageNum + "/" + this.pageSize
      this.$axios.get(url).then(r=>{
        console.log(r.data)
        this.providerAudit = r.data.records
        this.total = r.data.total
        this.providerAudit.forEach(r=>{
          if(r.returntype==0){
            r.returntype='待审核'
          }
          else if(r.returntype==1){
            r.returntype='退货成功'
          }
          else if(r.returntype==2){
            r.returntype='退货失败'
          }
          else if(r.returntype==3){
            r.returntype='同意退货'
          }
          if(r.returnmoney==0){
            r.returnmoney='待审核'
          }
          else if(r.returnmoney==1){
            r.returnmoney='退款成功'
          }
          else if(r.returnmoney==2){
            r.returnmoney='退款失败'
          }
        })
      })
    },
    handleSizeChange(val) {
      this.pageSize = val
      this.init()
    },
    handleCurrentChange(val) {
      this.pageNum = val
      this.init()
    },
    handleClick(row){
      this.usercodeTag = row.id
      this.dialogVisible = true
      this.$refs.child1.init(this.usercodeTag);
    },
    closeWin(){
      this.init()
      this.dialogVisible = false
    }
  }
}
</script>

<style scoped>

</style>